package com.ruoyi.system.bond.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.bond.domain.Bond;
import com.ruoyi.system.bond.service.IBondService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 可转债基础信息Controller
 * 
 * @author Galaxy
 * @date 2024-11-25
 */
@RestController
@RequestMapping("/bond/basic")
public class BondController extends BaseController
{
    @Autowired
    private IBondService bondService;

    /**
     * 查询可转债基础信息列表
     */
    @PreAuthorize("@ss.hasPermi('bond:basic:list')")
    @GetMapping("/list")
    public TableDataInfo list(Bond bond)
    {
        startPage();
        List<Bond> list = bondService.selectBondList(bond);
        return getDataTable(list);
    }

    /**
     * 导出可转债基础信息列表
     */
    @PreAuthorize("@ss.hasPermi('bond:basic:export')")
    @Log(title = "可转债基础信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Bond bond)
    {
        List<Bond> list = bondService.selectBondList(bond);
        ExcelUtil<Bond> util = new ExcelUtil<Bond>(Bond.class);
        util.exportExcel(response, list, "可转债基础信息数据");
    }

    /**
     * 获取可转债基础信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('bond:basic:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bondService.selectBondById(id));
    }

    /**
     * 新增可转债基础信息
     */
    @PreAuthorize("@ss.hasPermi('bond:basic:add')")
    @Log(title = "可转债基础信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Bond bond)
    {
        return toAjax(bondService.insertBond(bond));
    }

    /**
     * 修改可转债基础信息
     */
    @PreAuthorize("@ss.hasPermi('bond:basic:edit')")
    @Log(title = "可转债基础信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Bond bond)
    {
        return toAjax(bondService.updateBond(bond));
    }

    /**
     * 删除可转债基础信息
     */
    @PreAuthorize("@ss.hasPermi('bond:basic:remove')")
    @Log(title = "可转债基础信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bondService.deleteBondByIds(ids));
    }
}
